package com.mini.repository;

import com.mini.model.BusinessBaseInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Set;

/**
 * @author zhangxiaobin
 * @title: MiniLessonBaseInfoRepository
 * @description: TODO
 * @date 2019/10/2711:33
 */
@Repository
public interface BusinessBaseInfoRepository extends JpaRepository<BusinessBaseInfo, Long>, JpaSpecificationExecutor<BusinessBaseInfo> {

    @Query(value = "SELECT b.group_id ,group_concat(b.mini_lesson_id) lessonIds  FROM business_base_info b GROUP BY b.group_id",nativeQuery = true)
    List<Object[]> groupLessonData();

    List<BusinessBaseInfo> findAllByMiniLessonIdIn(Set<Long> ids);
    
    List<BusinessBaseInfo> findBySiteType(Integer siteType);

    List<BusinessBaseInfo> findBySiteTypeAndXingtuSite(Integer siteType,String xingtuSite);

}
